<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理员页面</title>
</head>
<script src="https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js">
</script>
<style>
    * {
        margin: 0px;
        padding: 0px;
    }

    #box {
        width: 100%;
        height: 600px;
        position: relative;
    }

    #top {
        width: 100%;
        height: 100px;
        background-image: url("/image/top.jpg");
        background-repeat: no-repeat;
        background-size: 100% 100px;
    }

    #top1 {
        height: 100px;
        width: 200px;
        padding: 25px;
    }

    #top2 {
        height: 100px;
        width: 250px;
        position: absolute;
        left: 1200px;
        top: 60px;
        font-size: 20px;
    }

    #option {
        width: 200px;
        height: 500px;

    }

    .option1, .option2, .option3, .option4, .option5 {
        width: 200px;
        height: 50px;
        text-align: center;
        font-size: 20px;
        cursor: pointer;
    }

    .click {
        background-image: url("/image/click.jpg");
        background-repeat: no-repeat;
        background-size: 200px 50px;
    }

    .content {
        width: 80%;
        height: 500px;
        position: absolute;
        left: 200px;
        top: 100px;
    }

    .content1 {
        width: 80%;
        height: 500px;
        position: absolute;
        left: 300px;
        top: 0px;
    }

    .table {
        width: 650px;
    }

    .btn {
        width: 50px;
        height: 35px;
        cursor: pointer;
    }

    button {
        cursor: pointer;
    }

    .insert {
        width: 50px;
        height: 35px;
        position: absolute;
        left: 600px;
    }

    .userInsert {
        width: 50px;
        height: 35px;
        position: absolute;
        left: 350px;
    }
</style>
<body>
<div id="box">
    <div id="top">
        <div id="top1">
            <h1>图书管理系统</h1>
        </div>
        <div id="top2">
            欢迎您:<span class="user"></span>
            角色:<span class="role">管理员</span>
        </div>
    </div>
    <div id="option">
        <div class="option1">首页</div>
        <div class="option2">图书管理</div>
        <div class="option3">用户管理</div>
        <div class="option4">修改密码</div>
        <div class="option5">退出系统</div>
        <div class="content">

        </div>
    </div>
</div>
</body>
<script>

    var user;
    $(function () {
        $.ajax({
            url: "managerIdentityServlet",
            type: "post",
            success: function (s) {
                user = s;
                $(".user").append(s);
            }
        })

        //首页
        function load() {
            $(".option1").attr("class", "option1 click");
            $(".option2").attr("class", "option2");
            $(".option3").attr("class", "option3");
            $(".option4").attr("class", "option4");
            $(".option5").attr("class", "option5");
            $.ajax({
                url: "managerHomeServlet",
                type: "post",
                success: function (s) {
                    $(".content").html("<h1 style='text-align: center'>" + s + "</h1>");
                }
            })
        }

        $(".option1").click(function () {
            load()
        });
        $(".option1").ready(function () {
            load()
        });
    })


    var currentPage = 0;
    var totalPage = 0;
    var search1;
    var search2;

    function Ajax(s) {
        let s1 = s.list;
        currentPage = s.currentPage;
        totalPage = s.totalPage;
        let str = "<div class='content1'>" +
            "书名:<input type=\"text\" class=\"bookname\" style='height: 25px'>\n" +
            "作者:<input type=\"text\" class=\"auther\"  style='height: 25px'>\n" +
            " <button class='btn'>查询</button> " +
            "<button class='insert'>添加</button> " +
            "<table border='1px' class='table'>\n" +
            "    <tr>\n" +
            "        <td><input type='checkbox' class='check'></td>\n" +
            "        <td>id</td>\n" +
            "        <td>书名</td>\n" +
            "        <td>作者</td>\n" +
            "        <td>价格</td>\n" +
            "        <td>数量</td>\n" +
            "        <td>操作</td>\n" +
            "    </tr>" +
            "</div>"
        $(".content").html(str);
        for (let i = 0; i < s1.length; i++) {
            let str1 = "    <tr>\n" +
                "      <td><input type='checkbox' class='check'></td>\n" +
                "        <td>" + s1[i].id + "</td>\n" +
                "        <td>" + s1[i].bookname + "</td>\n" +
                "        <td>" + s1[i].auther + "</td>\n" +
                "        <td>" + s1[i].price + "</td>\n" +
                "        <td>" + s1[i].nums + "</td>\n" +
                "        <td><a href='javascript:void(0)' name='" + s1[i].id + "' class=\"update\">修改</a>" +
                "        <a href='javascript:void(0)' name='" + s1[i].id + "' class=\"delete\">删除</a></td>" +
                "  </tr>"
            $(".table").append(str1);
        }
        let str2 = "<button class=\"btn1\">首页</button>     <button class=\"btn2\">上一页</button>" +
            "<button class=\"btn3\">下一页</button>     <button class=\"btn4\">末页</button>" +
            "<span style='font-size: 25px'>共" + s.totalCount + "条记录,共" + s.totalPage + "页</span>"
        $(".table").after(str2);

        //删除
        for (let i = 0; i < 4; i++) {
            $(".delete").eq(i).click(function () {
                if (confirm("是否要删除这条记录?")) {
                    let id = $(".delete").eq(i).attr("name");
                    $.ajax({
                        url: "managerDeleteBookServlet",
                        type: "post",
                        data: "id=" + id,
                        success: function () {
                            alert("删除成功!")
                            location.reload(true);
                        }
                    })
                }
            });
            //修改
            $(".update").eq(i).click(function () {
                let id = $(".update").eq(i).attr("name");
                $.ajax({
                    url: "managerFindBookServlet",
                    type: "post",
                    data: "id=" + id,
                    success: function (s) {
                        let str = "<div class='content1'>" +
                            "<table>" +
                            "<tr>" +
                            "<td>书名:</td>" +
                            "<td><input type='text' value='" + s.bookname + "' class='bookname'></td>" +
                            "</tr>" +
                            "<tr>" +
                            "<td>作者:</td>" +
                            "<td><input type='text' value='" + s.auther + "' class='auther'></td>" +
                            "</tr>" +
                            "<tr>" +
                            "<td>价格:</td>" +
                            "<td><input type='text' value='" + s.price + "' class='price'></td>" +
                            "</tr>" +
                            "<tr>" +
                            "<td>数量:</td>" +
                            "<td><input type='text' value='" + s.nums + "' class='nums'></td>" +
                            "</tr>" +
                            "<tr>" +
                            "<td></td>" +
                            "<td><button class='submit'>提交</button></td>" +
                            "</tr>" +
                            "</table>" +
                            "</div>"
                        $(".content").html(str);
                        $(".submit").click(function () {
                            let bookname = $(".bookname").val();
                            let auther = $(".auther").val();
                            let price = $(".price").val();
                            let nums = $(".nums").val();
                            var book = {
                                "id": id, "bookname": bookname, "auther": auther,
                                "price": price, "nums": nums
                            }
                            $.ajax({
                                url: "managerUpdateBookServlet",
                                type: "post",
                                data: "book=" + JSON.stringify(book),
                                success: function () {
                                    location.reload(true);
                                }
                            })
                        });
                    }
                })
            });
        }

        //添加
        $(".insert").click(function () {
            let str = "<div class='content1'>" +
                "<table>" +
                "<tr>" +
                "<td>Id:</td>" +
                "<td><input type='text'  class='id'></td>" +
                "</tr>" +
                "<tr>" +
                "<td>书名:</td>" +
                "<td><input type='text'  class='bookname'></td>" +
                "</tr>" +
                "<tr>" +
                "<td>作者:</td>" +
                "<td><input type='text'  class='auther'></td>" +
                "</tr>" +
                "<tr>" +
                "<td>价格:</td>" +
                "<td><input type='text'  class='price'></td>" +
                "</tr>" +
                "<tr>" +
                "<td>数量:</td>" +
                "<td><input type='text'  class='nums'></td>" +
                "</tr>" +
                "<tr>" +
                "<td></td>" +
                "<td><button class='submit1'>提交</button></td>" +
                "</tr>" +
                "</table>" +
                "</div>"
            $(".content").html(str);
            $(".submit1").click(function () {
                let id = $(".id").val();
                let bookname = $(".bookname").val();
                let auther = $(".auther").val();
                let price = $(".price").val();
                let nums = $(".nums").val();
                var book = {
                    "id": id, "bookname": bookname, "auther": auther,
                    "price": price, "nums": nums
                }
                $.ajax({
                    url: "managerInsertBookServlet",
                    type: "post",
                    data: "book=" + JSON.stringify(book),
                    success: function (s) {
                        if (s) {
                            alert("添加成功!")
                            location.reload(true)
                        } else {
                            alert("id不能相同!")
                        }
                    }
                })
            });
        });
        //首页
        $(".btn1").click(function () {
            $.ajax({
                url: "userFindByPageServlet",
                type: "post",
                data: "currentPage=1",
                success: function (s) {
                    Ajax(s)
                }
            })
        });
        //上一页
        $(".btn2").click(function () {
            $.ajax({
                url: "userFindByPageServlet",
                type: "post",
                data: "currentPage=" + (parseInt(currentPage) - 1),
                success: function (s) {
                    Ajax(s)
                }
            })
        });

        //末页
        $(".btn4").click(function () {
            $.ajax({
                url: "userFindByPageServlet",
                type: "post",
                data: "currentPage=" + totalPage,
                success: function (s) {
                    Ajax(s)
                }
            })
        });
        //下一页
        $(".btn3").click(function () {
            $.ajax({
                url: "userFindByPageServlet",
                type: "post",
                data: "currentPage=" + (parseInt(currentPage) + 1) + "&totalPage=" + totalPage,
                success: function (s) {
                    Ajax(s)
                }
            })
        });
        //搜素
        $(".btn").click(function () {
            search1 = $(".bookname").val();
            search2 = $(".auther").val();
            $.ajax({
                url: "userSearchByPageServlet",
                type: "post",
                data: "bookname=" + search1 + "&auther=" + search2,
                success: function (s) {
                    Search(s)
                }
            })
        })

        //搜素
        function Search(s) {
            let s1 = s.list;
            currentPage = s.currentPage;
            totalPage = s.totalPage;
            let str = "<div class='content1'>" +
                "书名:<input type=\"text\" class=\"bookname\"   style='height: 25px'>\n" +
                "作者:<input type=\"text\" class=\"auther\"  style='height: 25px'>\n" +
                " <button class='btn'>查询</button> " +
                "<table border='1px' class='table'>\n" +
                "    <tr>\n" +
                "        <td>id</td>\n" +
                "        <td>书名</td>\n" +
                "        <td>作者</td>\n" +
                "        <td>价格</td>\n" +
                "        <td>数量</td>\n" +
                "        <td>操作</td>\n" +
                "    </tr>" +
                "</div>"
            $(".content").html(str);
            for (let i = 0; i < s1.length; i++) {
                let str1 = "    <tr>\n" +
                    "        <td>" + s1[i].id + "</td>\n" +
                    "        <td>" + s1[i].bookname + "</td>\n" +
                    "        <td>" + s1[i].auther + "</td>\n" +
                    "        <td>" + s1[i].price + "</td>\n" +
                    "        <td>" + s1[i].nums + "</td>\n" +
                    "        <td><a href='javascript:void(0)' name='" + s1[i].id + "' class=\"update\">修改</a>" +
                    "        <a href='javascript:void(0)' name='" + s1[i].id + "' class=\"delete\">删除</a></td>" +
                    "  </tr>"
                $(".table").append(str1);
            }
            let str2 = "<button class=\"btn1\">首页</button>     <button class=\"btn2\">上一页</button>" +
                "<button class=\"btn3\">下一页</button>     <button class=\"btn4\">末页</button>" +
                "<span style='font-size: 25px'>共" + s.totalCount + "条记录,共" + s.totalPage + "页</span>"
            $(".table").after(str2);

            //删除
            for (let i = 0; i < 4; i++) {
                $(".delete").eq(i).click(function () {
                    if (confirm("是否要删除这条记录?")) {
                        let id = $(".delete").eq(i).attr("name");
                        $.ajax({
                            url: "managerDeleteBookServlet",
                            type: "post",
                            data: "id=" + id,
                            success: function () {
                                alert("删除成功!")
                                location.reload(true);
                            }
                        })
                    }
                });
                //修改
                $(".update").eq(i).click(function () {
                    let id = $(".update").eq(i).attr("name");
                    $.ajax({
                        url: "managerFindBookServlet",
                        type: "post",
                        data: "id=" + id,
                        success: function (s) {
                            let str = "<div class='content1'>" +
                                "<table>" +
                                "<tr>" +
                                "<td>书名:</td>" +
                                "<td><input type='text' value='" + s.bookname + "' class='bookname'></td>" +
                                "</tr>" +
                                "<tr>" +
                                "<td>作者:</td>" +
                                "<td><input type='text' value='" + s.auther + "' class='auther'></td>" +
                                "</tr>" +
                                "<tr>" +
                                "<td>价格:</td>" +
                                "<td><input type='text' value='" + s.price + "' class='price'></td>" +
                                "</tr>" +
                                "<tr>" +
                                "<td>数量:</td>" +
                                "<td><input type='text' value='" + s.nums + "' class='nums'></td>" +
                                "</tr>" +
                                "<tr>" +
                                "<td></td>" +
                                "<td><button class='submit'>提交</button></td>" +
                                "</tr>" +
                                "</table>" +
                                "</div>"
                            $(".content").html(str);
                            $(".submit").click(function () {
                                let bookname = $(".bookname").val();
                                let auther = $(".auther").val();
                                let price = $(".price").val();
                                let nums = $(".nums").val();
                                var book = {
                                    "id": id, "bookname": bookname, "auther": auther,
                                    "price": price, "nums": nums
                                }
                                $.ajax({
                                    url: "managerUpdateBookServlet",
                                    type: "post",
                                    data: "book=" + JSON.stringify(book),
                                    success: function () {
                                        location.reload(true);
                                    }
                                })
                            });
                        }
                    })
                });
            }


            //首页
            $(".btn1").click(function () {
                $.ajax({
                    url: "userSearchByPageServlet",
                    type: "post",
                    data: "currentPage=1&bookname=" + search1 + "&auther=" + search2,
                    success: function (s) {
                        Search(s)
                    }
                })
            });
            //上一页
            $(".btn2").click(function () {
                $.ajax({
                    url: "userSearchByPageServlet",
                    type: "post",
                    data: "currentPage=" + (parseInt(currentPage) - 1) + "&bookname=" + search1 + "&auther=" + search2,
                    success: function (s) {
                        Search(s)
                    }
                })
            });

            //末页
            $(".btn4").click(function () {
                $.ajax({
                    url: "userSearchByPageServlet",
                    type: "post",
                    data: "currentPage=" + totalPage + "&bookname=" + search1 + "&auther=" + search2,
                    success: function (s) {
                        Search(s)
                    }
                })
            });
            //下一页
            $(".btn3").click(function () {
                $.ajax({
                    url: "userSearchByPageServlet",
                    type: "post",
                    data: "currentPage=" + (parseInt(currentPage) + 1) + "&totalPage=" + totalPage + "&bookname=" + search1 + "&auther=" + search2,
                    success: function (s) {
                        Search(s)
                    }
                })
            });
            //搜素
            $(".btn").click(function () {
                search1 = $(".bookname").val();
                search2 = $(".auther").val();
                $.ajax({
                    url: "userSearchByPageServlet",
                    type: "post",
                    data: "bookname=" + search1 + "&auther=" + search2,
                    success: function (s) {
                        Search(s)
                    }
                })
            });
            //添加
            $(".insert").click(function () {
                let str = "<div class='content1'>" +
                    "<table>" +
                    "<tr>" +
                    "<td>Id:</td>" +
                    "<td><input type='text'  class='id'></td>" +
                    "</tr>" +
                    "<tr>" +
                    "<td>书名:</td>" +
                    "<td><input type='text'  class='bookname'></td>" +
                    "</tr>" +
                    "<tr>" +
                    "<td>作者:</td>" +
                    "<td><input type='text'  class='auther'></td>" +
                    "</tr>" +
                    "<tr>" +
                    "<td>价格:</td>" +
                    "<td><input type='text'  class='price'></td>" +
                    "</tr>" +
                    "<tr>" +
                    "<td>数量:</td>" +
                    "<td><input type='text'  class='nums'></td>" +
                    "</tr>" +
                    "<tr>" +
                    "<td></td>" +
                    "<td><button class='submit1'>提交</button></td>" +
                    "</tr>" +
                    "</table>" +
                    "</div>"
                $(".content").html(str);
                $(".submit1").click(function () {
                    let id = $(".id").val();
                    let bookname = $(".bookname").val();
                    let auther = $(".auther").val();
                    let price = $(".price").val();
                    let nums = $(".nums").val();
                    var book = {
                        "id": id, "bookname": bookname, "auther": auther,
                        "price": price, "nums": nums
                    }
                    $.ajax({
                        url: "managerInsertBookServlet",
                        type: "post",
                        data: "book=" + JSON.stringify(book),
                        success: function (s) {
                            if (s) {
                                alert("添加成功!")
                                location.reload(true)
                            } else {
                                alert("id不能相同!")
                            }
                        }
                    })
                });
            });
        }

        //全选
        $(".check").eq(0).click(function () {
            var check = $(".check").eq(0).prop("checked")
            for (let i = 1; i < $(".check").length; i++) {
                $(".check").eq(i).prop("checked", check);
            }
        });
        //一个没选则全选不会被选
        for (let i = 1; i < $(".check").length; i++) {
            $(".check").eq(i).click(function () {
                if ($(".check").eq(i).prop("checked") === false) {
                    $(".check").eq(0).prop("checked", false);
                }
            });
        }
    }

    //图书管理
    $(".option2").click(function () {
        $(".option1").attr("class", "option1");
        $(".option2").attr("class", "option2 click");
        $(".option3").attr("class", "option3");
        $(".option4").attr("class", "option4");
        $(".option5").attr("class", "option5");
        $.ajax({
            url: "userFindByPageServlet",
            type: "post",
            success: function (s) {
                Ajax(s)
            }
        })
    });

    function Manager(s) {
        let s1 = s.list;
        currentPage = s.currentPage;
        totalPage = s.totalPage;
        let str = "<div class='content1'>" +
            "用户名:<input type=\"text\" class=\"username\" style='height: 25px'>\n" +
            " <button class='btn'>查询</button> " +
            " <button class='userInsert'>添加</button> " +
            "<table border='1px' style='width: 400px' class='table'>\n" +
            "    <tr>\n" +
            "        <td>id</td>\n" +
            "        <td>用户名</td>\n" +
            "        <td>密码</td>\n" +
            "        <td>操作</td>\n" +
            "    </tr>" +
            "</div>"
        $(".content").html(str);
        for (let i = 0; i < s1.length; i++) {
            let str1 = "    <tr>\n" +
                "        <td>" + s1[i].id + "</td>\n" +
                "        <td>" + s1[i].username + "</td>\n" +
                "        <td>" + s1[i].password + "</td>\n" +
                "        <td><a href='javascript:void(0)' name='" + s1[i].id + "' class=\"find\">查看</a>" +
                "        <a href='javascript:void(0)' name='" + s1[i].id + "' class=\"delete\">删除</a></td>" +
                "  </tr>"
            $(".table").append(str1);
        }
        let str2 = "<button class=\"btn1\">首页</button>     <button class=\"btn2\">上一页</button>" +
            "<button class=\"btn3\">下一页</button>     <button class=\"btn4\">末页</button>" +
            "<span style='font-size: 25px'>共" + s.totalCount + "条记录,共" + s.totalPage + "页</span>"
        $(".table").after(str2);

        //删除
        for (let i = 0; i < 4; i++) {
            $(".delete").eq(i).click(function () {
                if (confirm("是否要删除这条记录?")) {
                    let id = $(".delete").eq(i).attr("name");
                    $.ajax({
                        url: "managerDeleteUserServlet",
                        type: "post",
                        data: "id=" + id,
                        success: function () {
                            alert("删除成功!")
                            location.reload(true);
                        }
                    })
                }
            });
            //查看
            $(".find").eq(i).click(function () {
                let id = $(".find").eq(i).attr("name");
                $.ajax({
                    url: "managerFindBorrowBookServlet",
                    type: "post",
                    data: "id=" + id,
                    success: function (s) {
                        let str = "<div class='content1'>" +
                            "<table border='1px' class='table'>\n" +
                            "    <tr>\n" +
                            "        <td>id</td>\n" +
                            "        <td>书名</td>\n" +
                            "        <td>作者</td>\n" +
                            "        <td>价格</td>\n" +
                            "        <td>操作</td>\n" +
                            "    </tr>" +
                            "</div>"
                        $(".content").html(str);
                        for (let i = 0; i < s.length; i++) {
                            let str1 = "    <tr>\n" +
                                "        <td>" + s[i].id + "</td>\n" +
                                "        <td>" + s[i].bookname + "</td>\n" +
                                "        <td>" + s[i].auther + "</td>\n" +
                                "        <td>" + s[i].price + "</td>\n" +
                                "       <td><a href='javascript:void(0)' name='" + s[i].id + "' class=\"delete\">删除</a></td>" +
                                "  </tr>"
                            $(".table").append(str1);
                            $(".delete").eq(i).click(function () {
                                $.ajax({
                                    url: "managerDeleteBorrowBookServlet",
                                    type: "post",
                                    data: "id=" + s[i].id,
                                    success: function () {
                                        location.reload(true)
                                    }
                                })
                            });
                        }
                    }
                })
            });
        }

        //首页
        $(".btn1").click(function () {
            $.ajax({
                url: "managerUserByPageServlet",
                type: "post",
                data: "currentPage=1",
                success: function (s) {
                    Manager(s)
                }
            })
        });
        //上一页
        $(".btn2").click(function () {
            $.ajax({
                url: "managerUserByPageServlet",
                type: "post",
                data: "currentPage=" + (parseInt(currentPage) - 1),
                success: function (s) {
                    Manager(s)
                }
            })
        });

        //末页
        $(".btn4").click(function () {
            $.ajax({
                url: "managerUserByPageServlet",
                type: "post",
                data: "currentPage=" + totalPage,
                success: function (s) {
                    Manager(s)
                }
            })
        });
        //下一页
        $(".btn3").click(function () {
            $.ajax({
                url: "managerUserByPageServlet",
                type: "post",
                data: "currentPage=" + (parseInt(currentPage) + 1) + "&totalPage=" + totalPage,
                success: function (s) {
                    Manager(s)
                }
            })
        });
        //搜素
        $(".btn").click(function () {
            search1 = $(".username").val();

            $.ajax({
                url: "managerSearchUserByPageServlet",
                type: "post",
                data: "username=" + search1,
                success: function (s) {
                    SearchUser(s)
                }
            })
        })

        function SearchUser(s) {
            let s1 = s.list;
            currentPage = s.currentPage;
            totalPage = s.totalPage;
            let str = "<div class='content1'>" +
                "用户名:<input type=\"text\" class=\"username\" style='height: 25px'>\n" +
                " <button class='btn'>查询</button> " +
                "<table border='1px' style='width: 400px' class='table'>\n" +
                "    <tr>\n" +
                "        <td>id</td>\n" +
                "        <td>用户名</td>\n" +
                "        <td>密码</td>\n" +
                "    </tr>" +
                "</div>"
            $(".content").html(str);
            for (let i = 0; i < s1.length; i++) {
                let str1 = "    <tr>\n" +
                    "        <td>" + s1[i].id + "</td>\n" +
                    "        <td>" + s1[i].username + "</td>\n" +
                    "        <td>" + s1[i].password + "</td>\n" +
                    "        <td><a href='javascript:void(0)' name='" + s1[i].id + "' class=\"find\">查看</a>" +
                    "        <a href='javascript:void(0)' name='" + s1[i].id + "' class=\"delete\">删除</a></td>" +
                    "  </tr>"
                $(".table").append(str1);
            }
            let str2 = "<button class=\"btn1\">首页</button>     <button class=\"btn2\">上一页</button>" +
                "<button class=\"btn3\">下一页</button>     <button class=\"btn4\">末页</button>" +
                "<span style='font-size: 25px'>共" + s.totalCount + "条记录,共" + s.totalPage + "页</span>"
            $(".table").after(str2);

            //删除
            for (let i = 0; i < 4; i++) {
                $(".delete").eq(i).click(function () {
                    if (confirm("是否要删除这条记录?")) {
                        let id = $(".delete").eq(i).attr("name");
                        $.ajax({
                            url: "managerDeleteUserServlet",
                            type: "post",
                            data: "id=" + id,
                            success: function () {
                                alert("删除成功!")
                                location.reload(true);
                            }
                        })
                    }
                });
            }

            //首页
            $(".btn1").click(function () {
                $.ajax({
                    url: "managerSearchUserByPageServlet",
                    type: "post",
                    data: "currentPage=1&username=" + search1,
                    success: function (s) {
                        SearchUser(s)
                    }
                })
            });
            //上一页
            $(".btn2").click(function () {
                $.ajax({
                    url: "managerSearchUserByPageServlet",
                    type: "post",
                    data: "currentPage=" + (parseInt(currentPage) - 1) + "&username=" + search1,
                    success: function (s) {
                        SearchUser(s)
                    }
                })
            });

            //末页
            $(".btn4").click(function () {
                $.ajax({
                    url: "managerSearchUserByPageServlet",
                    type: "post",
                    data: "currentPage=" + totalPage + "&username=" + search1,
                    success: function (s) {
                        SearchUser(s)
                    }
                })
            });
            //下一页
            $(".btn3").click(function () {
                $.ajax({
                    url: "managerSearchUserByPageServlet",
                    type: "post",
                    data: "currentPage=" + (parseInt(currentPage) + 1) + "&totalPage=" + totalPage + "&username=" + search1,
                    success: function (s) {
                        SearchUser(s)
                    }
                })
            });
            //搜素
            $(".btn").click(function () {
                search1 = $(".username").val();
                $.ajax({
                    url: "managerSearchUserByPageServlet",
                    type: "post",
                    data: "username=" + search1,
                    success: function (s) {
                        SearchUser(s)
                    }
                })
            });
        }
    }

    //修改密码
    $(".option4").click(function () {
        $(".option1").attr("class", "option1");
        $(".option2").attr("class", "option2 ");
        $(".option3").attr("class", "option3");
        $(".option4").attr("class", "option4 click");
        $(".option5").attr("class", "option5");
        let s =
            "<div class='content1'>" +
            "<table style='width: 400px' >" +
            "<tr>" +
            "<td>原密码:</td>" +
            "<td><input type='password' class='pwd1'></td>" +
            "<td class='td1'></td>" +
            "</tr>" +
            "<tr>" +
            "<td>新密码:</td>" +
            "<td><input type='password' class='pwd2'></td>" +
            "<td class='td2'></td>" +
            "</tr>" +
            "<tr>" +
            "<td>确认密码:</td>" +
            "<td><input type='password' class='pwd3'></td>" +
            "<td class='td2'></td>" +
            "</tr>" +
            "<tr>" +
            "<td></td>" +
            "<td><button class='submit'>提交</button></td>" +
            "<td></td>" +
            "</tr>" +
            "</table>" +
            "</div>"
        $(".content").html(s);

        $(".submit").click(function () {
            let pwd1 = $(".pwd1").val();
            let pwd2 = $(".pwd2").val();
            let pwd3 = $(".pwd3").val();
            if (pwd2 === pwd3) {
                $(".td2").html("")
                $.ajax({
                    url: "managerUpdateServlet",
                    type: "post",
                    data: "username=" + user + "&password1=" + pwd1 + "&password2=" + pwd2,
                    success: function (s) {
                        if (s) {
                            alert("密码修改成功!")
                            $(".td1").html("")
                            location.reload(true);
                        } else {
                            $(".td1").html("<span style='color: red'>原密码不正确!</span>")
                        }
                    }
                })
            } else {
                $(".td2").html("<span style='color: red'>俩次密码不一致!</span>")
            }
        });
    });

    //用户管理
    $(".option3").click(function () {
        $(".option1").attr("class", "option1");
        $(".option2").attr("class", "option2");
        $(".option3").attr("class", "option3 click");
        $(".option4").attr("class", "option4");
        $(".option5").attr("class", "option5");
        $.ajax({
            url: "managerUserByPageServlet",
            type: "post",
            success: function (s) {
                Manager(s)
            }
        })
    });

    //退出系统
    $(".option5").click(function () {
        $(".option1").attr("class", "option1");
        $(".option2").attr("class", "option2 ");
        $(".option3").attr("class", "option3");
        $(".option4").attr("class", "option4");
        $(".option5").attr("class", "option5 click");
        if (confirm("是否要退出本系统?") == true) {
            location.href = "Login.html"
        }
    });
</script>
</html>